package com.siants.util;


import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Enumeration;
import java.util.Properties;

/**
 * Created by yanxin on 2017/7/11.
 */
public class PropertyUtil {

    public void initProperty(){
        Property property = new Property();
        Properties ps = property.readProperty();
        Enumeration e = ps.propertyNames();
        while (e.hasMoreElements()){
            String key = (String)e.nextElement();
            PropertyCacheMap.setCache(key,ps.getProperty(key));
        }
    }

    public void initProperty(String propertyFileName){
        Property property = new Property();
        Properties ps = new Properties();
        try {
            ps.load(new InputStreamReader(property.getClass().getClassLoader().getResourceAsStream(propertyFileName),"GBK"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        Enumeration e = ps.propertyNames();
        while (e.hasMoreElements()){
            String key = (String)e.nextElement();
            PropertyCacheMap.setCache(key,ps.getProperty(key));
        }
    }

}
